package com.ruoyi.web.controller.business;


import com.ruoyi.business.domain.ListType;
import com.ruoyi.business.service.CivilServantsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/statistics")
@Api(tags = {"首页统计相关接口控制器"})
public class StatisticsController extends BaseController {

    @Autowired
    CivilServantsService civilServantsService;

    @GetMapping("/sumUser")
    @ApiOperation("统计录入的人员数量接口")
    public AjaxResult sum(@ApiParam(value = "用户id",required = false) Long userId) {
//        Long userid = SecurityUtils.getUserId();
        int sum = civilServantsService.sum(userId);
        return success(sum);
    }

    @GetMapping("/degree")
    @ApiOperation("学历分布统计接口")
    public AjaxResult degree(@ApiParam(value = "用户id",required = false) Long userId,
                             @ApiParam(value = "职级，全部为0，处级为1，科级为2，其他为3",required = false) String type) {
//                Long userid = SecurityUtils.getUserId();
        AjaxResult degree = civilServantsService.getDegree(userId,type);
        return success(degree);
    }


    @GetMapping("/office")
    @ApiOperation("任正（副）处、科人数统计接口")
    public AjaxResult office(@ApiParam(value = "用户id",required = false) Long userId) {
//                Long userid = SecurityUtils.getUserId();
        AjaxResult office = civilServantsService.getOffice(userId);
        return success(office);
    }

}
